package cn.com.jslh.boarpro.main.model;

import android.content.Context;

import com.blankj.utilcode.util.SPUtils;

import java.util.List;

import cn.com.jslh.boarpro.base.BaseApplication;
import cn.com.jslh.boarpro.base.mvp.BaseListModel;
import cn.com.jslh.boarpro.tables.BreedRecordTable;
import cn.com.jslh.boarpro.util.WebService;
import cn.com.jslh.boarpro.util.database.DataBaseUtil;

/**
 * 作者：周洲 on 2017/7/28 10:41
 * <p>
 * 邮箱：double0zhou@126.com
 */

public class AddBreedingRecordModelImpl extends BaseListModel {


    public AddBreedingRecordModelImpl(Context context) {
        super(context);
    }

    @Override
    public List<?> getDatas(String... params) {
        return null;
    }

    public void asyncGetDatas(WebService.NetSuccessListener netSuccessListener) {
        new WebService.Builder(context, "exportBreederInfo", "WSZpigBaseDataFacade")
                .addProperty("orgID", SPUtils.getInstance().getString(BaseApplication.FORGID))
                .addProperty("lineID", SPUtils.getInstance().getString(BaseApplication.FLINEID))
                .addProperty("perType", "kvYAAAASDRrYXorS")
                .showDialog(true)
                .success(netSuccessListener)
                .post();
    }

    /**
     * 记录存入数据库
     *
     * @param params
     */
    public void save2Db(String... params) {
        BreedRecordTable breedRecordTable = new BreedRecordTable();
        breedRecordTable.setMuZhuID(params[0]);
        breedRecordTable.setGongZhu1ID(params[1]);
        breedRecordTable.setGongZhu2ID(params[2]);
        breedRecordTable.setGongZhu3ID(params[3]);
        breedRecordTable.setPzType(params[4]);
        breedRecordTable.setMuZhuErHao(params[5]);
        breedRecordTable.setGongZhu1ErHao(params[6]);
        breedRecordTable.setGongZhu2ErHao(params[7]);
        breedRecordTable.setGongZhu3ErHao(params[8]);
        breedRecordTable.setPzTypeStr(params[9]);
        breedRecordTable.setPzy(params[10]);
        breedRecordTable.setPzyID(params[11]);
        breedRecordTable.setLineID(SPUtils.getInstance().getString(BaseApplication.FLINEID));
        DataBaseUtil.saveObjectData(context, BreedRecordTable.class, breedRecordTable);
    }
}
